<template>
	<view class="content">
		<customHead
			:slideFlag="slideFlag"
			navi_background="#01cb88"
			:placeholder="true"
		>
		</customHead>
		<view class="payTop"></view>
		<view class="payBox">
			<image :src="payImg" style="width: 360rpx;height: 360rpx;" mode="aspectFill">
			</image>
			<view class="successText">恭喜您支付成功!</view>
			<view class="pay-money">
				<view v-if="scoreType==1">
					支付积分:<text class="pay-text">{{paytotalmoney}}积分</text>
				</view>
				<view v-else>
					支付金额:<text class="pay-text">￥{{paytotalmoney}}元</text>
				</view>
			</view>
			<view class="seeOrde common" style="opacity: 0.8;" v-if="id!=='' && second">
				查看订单
				<text>({{second}}s)</text>
			</view>
			<view class="seeOrde common" v-if="id!=='' && !second" @click="Topath()">
				查看订单
			</view>
			<view class="backHome common" @click="Tohome()">
				返回首页
			</view>
		</view>
	</view>
</template>

<script>
	import { getApplicationPlugsRecommendedList} from "@/tools/request/api.js"
	import JSONBig from 'json-bigint'
	export default {
		data() {
			return {
				paytotalmoney: '',
				id: '',
				scoreType: '',
				payImg: '',
				timer: null,
				second: 5
			}
		},
		onLoad(e) {
			let self = this;
			self.getImg()
			self.paytotalmoney = e.money;
			self.scoreType = e.score;
			self.id = JSONBig.parse(e.id).toString();
		},
		onReady () {
			this.timer = setInterval(() => {
				this.second--;
				if (this.second <= 0) {
					clearInterval(this.timer);
				}
			}, 1000)
		},
		onUnload () {
			clearInterval(this.timer);
		},
		methods: {
			Topath() {
				uni.redirectTo({
					url: '/pages/order/orderDetail/orderDetail?id=' + this.id
				})
			},
			Tohome() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			getImg() {
				let data = {
					businessId: this.businessId,
					userServiceToken: this.userServiceToken
				}
				getApplicationPlugsRecommendedList(data).then(res => {
					if (res.code == 200) {
						let list = res.body;
						let url = list.filter(itm => itm.type === 'paysuccess');
						self.payImg = url[0].activityImgUrl;
					}
				})
			},
		}
	}
</script>

<style lang="less">
	page {
		background-color: #f5f5f5;
	}

	.payTop {
		width: 100%;
		height: 240rpx;
		background-image: linear-gradient(#01cb88, #28efad, #fff);
		border-radius: 0 0 100rpx 100rpx;
	}

	.payBox {
		width: 92%;
		height: 1000rpx;
		// padding-bottom: 200rpx;
		border-radius: 20rpx;
		background-color: #fff;
		margin: 0 auto;
		margin-top: -160rpx;
		padding: 30rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		align-items: center;

		.successText {
			font-size: 36rpx;
			font-weight: bold;
			color: #01cb88;
			margin: 40rpx 0;
		}

		.pay-money {
			font-size: 30rpx;
			// margin-top: 40rpx;
			margin: 40rpx 0 80rpx 0;
		}

		.common {
			width: 84%;
			height: 100rpx;
			border-radius: 50rpx;
			text-align: center;
			line-height: 100rpx;
			font-size: 30rpx;
		}

		.seeOrde {
			background-image: linear-gradient(to right, #01cb88, #28efad);
			color: #f5f5f5;
			margin: 0 0 40rpx 0;
			// margin-bottom: 30rpx;
		}

		.backHome {
			border: 3rpx solid #01cb88;
			color: #01cb88;
		}
	}
</style>